//
//  ByViewLocation.m
//  chequanbao_ios
//
//  Created by mc on 2017/10/18.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByViewLocation.h"

@implementation ByViewLocation

- (instancetype)init{
    if (self = [super init]) {
        self.popMode = ZKBombPopModeTop;
        self.positionMode = ZKBombPositionModeCenter;
        self.damping = 0.6;
        self.aniDuration = 0.8;
        
        [self setupContents];
    }
    return self;
}

- (void)setupContents{
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 40, 140)];
    bgView.backgroundColor = [UIColor whiteColor];
    
    NSArray *imgs = @[@"Index_baidu",@"Index_gaode"];
    NSArray *titles = @[@"百度地图",@"高德地图"];
    CGFloat width = [titles[0] getSizeOfString:14].width + 5;
    for (int i = 0; i < imgs.count; i ++) {
        CGFloat control_x = (SCREEN_WIDTH - 40 - width * 2) / 3  * (i + 1) + width * i;
        UIControl *control = [[UIControl alloc] initWithFrame:CGRectMake(control_x, 30, width, 50 + 30)];
        control.tag = 10 + i;
        [bgView addSubview:control];
        
        UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake((width - 50) / 2, 0, 50, 50)];
        img.image = [UIImage imageNamed:imgs[i]];
        [control addSubview:img];
        
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 60, width, 20)];
        titleLabel.text = titles[i];
        titleLabel.font = FONT(14);
        titleLabel.textAlignment = NSTextAlignmentCenter;
        [control addSubview:titleLabel];
        [control addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    self.contentView = bgView;
}

- (void)clickAction:(UIControl *)control{
    if (self.clickBlock) {
        self.clickBlock(control.tag - 10);
    }
}



@end
